package com.scm.servlet.vender;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.scm.dao.VenderDao;
@WebServlet("/main/pomain/delvender")
public class DelVenderServlet extends HttpServlet{
	private static final long serialVersionUID = -8479807545191329999L;
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String vendercode = req.getParameter("vendercode");
		String currentpage = req.getParameter("currentpage");
		VenderDao venderdao = new VenderDao();
		try {
			venderdao.del(vendercode);
		} catch (SQLException e) {
			req.setAttribute("info", "有依赖记录，不可删除！");
		}finally {
			req.getRequestDispatcher("vender?currentpage="+currentpage).forward(req, resp);
		}
	}
}
